<?php
/**
 * api公共类
 */
namespace app\msgapi\controller;

use think\{App, Model};
use app\BaseController;
use app\msgapi\service\BaseService;

class Base extends BaseController
{

    protected Model $m;
    protected int $pid;
    protected array $class_type;

    protected BaseService $service;

    public function __construct(BaseService $service)
    {
        parent::__construct(app());
        $this->service = $service;
    }

    // 通用首页
    public function index()
    {
        return $this->service->getLists();
    }
    // 通用编辑
    public function edit(int $id = 0)
    {
        return $this->service->getRows($id);
    }
    // 通用保存
    public function save()
    {
        return $this->service->_save();
    }
    // 通用状态调整
    public function setStatus()
    {
        return $this->service->setStatus();
    }
    // 通用删除，适用于单、多选的
    public function delete( int $id = 0, array $ids = [])
    {
        return $this->service->_delete($ids?:$id);
    }

}